<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>应收结算单管理</title>
	<meta name="decorator" content="ani"/>
	<script type="text/javascript">

		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
					jp.loading();
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
	        $('#busyDate').datetimepicker({
				 format: "YYYY-MM-DD HH:mm:ss"
		    });
            //当结算日期为空时，赋值当前时间
            if($("#dd").val()==""){
                document.getElementById("dd").value = getNowFormatDate();
            }
            //初始状态默认为已输入
            if($("#status").val()==""){
                $("#status").val(0);
            }
		});
        <%--给日期赋初始值--%>
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var minute = date.getMinutes();
            if (minute >= 0 && minute <= 9) {
                minute = "0" + minute;
            }
            var seconds = date.getSeconds();
            if (seconds >= 0 && seconds <= 9) {
                seconds = "0" + seconds;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + date.getHours() + seperator2 + minute + seperator2 + seconds;
            return currentdate;
        }
        //点击确认按钮将已输入状态修改为已确认状态
        function verify(id,type){
            window.location.href="${ctx}/fee/receivables/updateStatus?id="+id+"&type="+type;
        }
        //刷新
        function refreshPage(id){
            window.location.href="${ctx}/fee/receivables/form?id="+id;
        }
        <%--引入明细按钮【引入费用明细的模态框】--%>
        function model(){
            var balance = $("#consignorSelect").val().trim();
            if(!balance){
                alert("请先选择结算方！");
                return;
            }else{
                $("#myModal").modal("show");
                all_ajax();
            }
        }
        <%--模态框提取数据ajax--%>
        function all_ajax(){
            //获取结算方
            var balance = $("#consignorSelect").val().trim();
            //获取查询框时间
            var startTime = $("#startDate").val().trim();
            var endTime = $("#endDate").val().trim();
            $.ajax({
                url: "${ctx}/fee/receivables/findAllDetail",
                // dataType:'json', feeType:0是收入  1是支出
                data: {"status": 0, "feeType": 0, "startTime": startTime,"endTime":endTime,"balance":balance},
                success: function(data) {
                    $("#detailLists").empty();
                    var list = eval(data);
                    console.log(list);
                    $.each(list,function(index,detail) {
                        var addTr = $("<tr id='"+detail.id+"'></tr>");
                        addTr.appendTo("#detailLists");
                        var td = ("<td>"+"<input id='"+detail.id+"' value='"+detail.id+"'  type='checkbox' class='i-checks'>"+"</td>");
                        addTr.append(td);
                        addTr.append($('<td></td>').text("未结算"));
                        addTr.append($("<td id='clearUnit_"+detail.id+"'>"+"</td>").text(detail.clearUnit.name));
                        addTr.append($('<td></td>').text(detail.feeAgreement.name));
                        addTr.append($('<td></td>').text(detail.feeType.name));
                        addTr.append($('<td></td>').text(detail.busyDate));
                        addTr.append($('<td></td>').text(detail.feeData));
                        addTr.append($('<td></td>').text(detail.payMoney));
                        addTr.append($('<td></td>').text(detail.clearingMoney));
                    })
                },
                error : function(data){
                }
            });
        }
        //获得所有选中的复选框的id
        function getCheckBox(){
            var boxs = "";		//设置变量，用于接收选中的复选框
            $("input:checkbox").each(function() {
                //判断复选框是否被选中
                if ($(this).is(':checked') && $(this).attr("id") != "allCheckBox") {
                    boxs += $(this).val();
                    boxs += ",";	//复选框的val()id集合以逗号分割
                }
            });
            //console.log(boxs);
            return boxs;
        }
        //点击提交后进行判断获取id
		function detail(){
            var tempIds = getCheckBox();
            var tempStr = tempIds.split(",");
            var ids = "";	//获取选中复选框的id
            var textName = "";
            if(tempIds == null || tempIds == ""){
                layer.alert("请至少选择一条数据！");
                return;
            }else{
                for(var i=0;i<tempIds.length/33;i++){
                    if($("#clearUnit_"+tempStr[i]).text()||$("#clearUnit_"+tempStr[i]).text()==""){
                        var text = $("#clearUnit_"+tempStr[i]).text().trim();
                        textName = !textName ? text : textName;
                        if(text == textName){
                            ids += tempStr[i]+",";
                        }else{
                            layer.alert("请选择相同的结算方!");
                            return;
                        }
                    }
                }
                //alert(ids);
            }
            $('#myModal').modal('hide')
            $(".modal-backdrop").removeClass('in');
            layer.load();
            $.ajax({
                url : "${ctx}/fee/receivables/addPayable",
                data : {		 //参数值
                    "ids" :ids,
                },
                type:"post",
                success : function(data) {
                    if(data){
                        var list = eval(data);
                        var clearMoney = $("#money").val()*1;//结算单的结算金额
                        var adjustMoney = 0 * 1;//调整金额
                        var clearUnit = "";
                        var ids = document.getElementById("ids");
                        $.each(list,function(index,term){
                            var addTr = $("<tr id='"+term.id+"'></tr>");
                            addTr.appendTo("#detailTbody");
                            var td = ("<td>"+"<input id='"+term.id+"' value='"+term.id+"' type='checkbox' class='i-checks'>"+"</td>");
                            addTr.append(td);
                            addTr.append($('<td></td>').text(term.busyDate));
                            addTr.append($('<td></td>').text(term.feeAgreement.name));
                            addTr.append($('<td></td>').text(term.feeType.name));
                            addTr.append($("<td id='"+term.id+"_payMoney'>"+"</td>").text(Number(term.payMoney).toFixed(2)));
                            addTr.append($("<td id='"+term.id+"_clearingMoney'>"+"</td>").text(Number(term.clearingMoney).toFixed(2)));
                            addTr.append("<td id='"+term.id+"_adjustSpread'>"+"</td>");
                            addTr.append("<td><a href='#' onclick=\"jp.openDialogView('查看费用明细', '${ctx}/fee/detail/form?id="+term.id+"','800px', '500px')\" class='btn btn-info btn-xs' ><i class='fa fa-search-plus'></i> 查看</a>"
                                +"&nbsp;<input onclick=\"deleteInPage('"+term.id+"')\"  type='button' value='删除' class='btn btn-danger btn-xs'>"+"</td>");
                            //clearMoney += term.payMoney;
                            //获取调整金额
                            adjustMoney = term.clearingMoney;
                            //判断调整金额是否为空
                            if (adjustMoney) {
                                clearMoney += term.clearingMoney;
                                //获取计费金额
                                var payMoney = term.payMoney;
                                //计算调整差额
                                var adjustSpread = Math.abs(payMoney-adjustMoney);
                                $("#"+term.id+"_adjustSpread").text(Number(adjustSpread).toFixed(2));
                            }else{
                                clearMoney += (adjustMoney+term.payMoney);
                            }
                            //alert("调整金额:"+adjustMoney+",结算金额："+clearMoney);
                            var tempId = ids.value;
                            tempId += term.id;
                            tempId += ",";
                            ids.value = tempId;
                            //获取结算方
                            clearUnit = term.clearUnit.name;
                        })
                        //如果结算金额异常，则置为0
                        clearMoney = clearMoney < 0 ? 0 : clearMoney;
                        //将结算单位填入应收结算单主表的合同签约方
                        $("#payerName").val(clearUnit);
                        //结算金额置为clearMoney
                        $("#money").val(Number(clearMoney).toFixed(2));
                        layer.closeAll('loading');
                    }else{
                        //结算金额置为0
                        $("#money").val(clearMoney);
                        layer.closeAll('loading');
                    }
                },
                error : function(data){
                    alert("操作失败!");
                    layer.closeAll('loading');
                }
            });
		}
        //不走后台，删除已经引入的明细
        function deleteInPage(id) {
            if (confirm("确定要删除吗？")) {
                //获取原来的结算金额
                var clearMoney = $("#money").val() * 1;
                //获取计费金额
                var payMoney = $("#" + id + "_payMoney").text() * 1;
                //获取结算金额
                var adjustMoney = $("#" + id + "_clearingMoney").text() * 1;
                if (adjustMoney) {//判断调整金额是否为空
                    //重新计算结算单的结算金额
                    var balanceMoney = clearMoney - adjustMoney;
                    $("#money").val(balanceMoney);
                } else {
                    //重新计算结算单的结算金额
                    var balanceMoney = clearMoney - payMoney;
                    $("#money").val(balanceMoney);
                }
                $("#detailTbody tr").each(function () {
                    var trId = $(this).attr("id");
                    if (trId == id) {
                        //获得页面原来的ids
                        var str = $("#ids").val();
                        var _str = str.trim().split(",");
                        str = "";
                        for (var i = 0; i < _str.length; i++) {
                            if (_str[i] == id) {
                                //ids删除id,ids中原来包含的id置为空字符串
                                _str[i] = "";
                            }
                            //重新追加ids的值
                            str += _str[i] + ",";
                        }
                        //ids重新赋值
                        $("#ids").val(str);
                        //tbody删除id= 传入id的一行数据
                        $(this).remove();
                    }
                })
            }
        }
        //开票操作
        function bill(id){
            <%--判断开票金额小于结算金额--%>
            var inv = $("#invoiceMoney").val().trim()*1;
            var money = $("#money").val().trim()*1;
            //alert(inv+","+money);

            var sum = inv < money ? 1 : 0;
            //alert(sum);
            if( sum){
                <%--var url = "${ctx}/fee/receivables/invoiceOperation?ids="+id+"&type=1";--%>
                <%--var a=document.body.offsetHeight-100+'px'--%>
                <%--openDialog("新增"+'应开发票',url,"${width==null?'900px':width}", "${height==null?'"+a+"':height}","${target}");--%>
                window.location.href="${ctx}/fee/receivables/invoiceOperation?ids="+id+"&type=1";
            }else{
                alert("开票金额小于结算金额才能继续开票");
                return;
            }

        }
        //获取弹出框上查询按钮
        function searchDetail() {
            //加载层-默认风格
            layer.load();
            //此处演示关闭
            setTimeout(function(){
                layer.closeAll('loading');
            },500);
            all_ajax();
        }
        //获取弹出框上重置按钮
        function reset(){//重置，页码清零
            $("#pageNo").val(0);
            $("#searchForm div.form-group input").val("");
            $("#searchForm div.form-group select").val("");
            //加载层-默认风格
            layer.load();
            //此处演示关闭
            setTimeout(function(){
                layer.closeAll('loading');
            },500);
            all_ajax();
            return false;

        }
        //关闭按钮弹出框的确定事件
        $(document).ready(function () {
            $("#confirmClose").click(function () {
                var pId = $("#pId").val();
                var closeReason = $("#closeReason").val();
                if(closeReason == null || closeReason == ""){
                    layer.alert("关闭原因不能为空,请填写关闭原因");
                }else{
                    $.ajax({
                        url : "${ctx}/fee/receivables/closeFeeReceivables",
                        data : {		 //参数值
                            "id" :pId,
                            "closeReason":closeReason
                        },
                        type:"post",
                        success : function(data) {
                            location.reload();
                        },
                        error : function(data){
                            alert("操作失败!");
                        }
                    });
                }
            })
        })
        //纠错[少收]
        function lessCorrect(id){
            <%--var url = "${ctx}/fee/feeReceivables/form?receId="+id;--%>
            <%--var a=document.body.offsetHeight-100+'px'--%>
            <%--openDialog("新增"+'应收结算单',url,"${width==null?'1000px':width}", "${height==null?'"+a+"':height}","${target}");--%>
            window.location.href="${ctx}/fee/receivables/form?receId="+id;
        }
        //纠错[多收]
        function moreCorrect(id){
            <%--var url = "${ctx}/fee/feePayable/form?receId="+id;--%>
            <%--var a=document.body.offsetHeight-100+'px'--%>
            <%--openDialog("新增"+'应付结算单',url,"${width==null?'1000px':width}", "${height==null?'"+a+"':height}","${target}");--%>
            window.location.href="${ctx}/fee/payable/form?receId="+id+"&typeSign=1";
        }
        $(document).ready(function() {
            $(".tab_2").click(function(){
                $(".detailedRecord").each(function () {
                    var trNum = $(".detailedRecord tr");
                    for(var i=0;i<trNum.length;i++){
                        var className = $(trNum[i]).prev().attr("class");
                        var className1=$(trNum[i]).next().attr("class");
                        if(className === "header" && className1 === "header"){
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"10px","margin-bottom":"10px"});
                        }else if(className === "header" && className1 === "detail"){
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"10px","margin-bottom":"0px"});
                        }else if(className === "detail" && className1 === "detail"){
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"0px","margin-bottom":"0px"});
                        }else if(className === "detail" && className1 === "header"){
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"0px","margin-bottom":"10px"});
                        }else if(className === "header" && trNum.length>=2){
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"10px","margin-bottom":"0px"});
                        }else{
                            $(trNum[i]).children(".progressBar").children("span").css({"margin-top":"0px","margin-bottom":"0px"});
                        }
                    }
                })
            })
        })
	</script>
</head>
<body>
<div class="wrapper wrapper-content">				
<div class="row">
	<div class="col-md-12">
	<div class="panel panel-primary">
		<%--应付结算单的多收冲账--%>
		<c:if test="${typeSign eq '1'}">
			<div class="panel-heading">
				<h3 class="panel-title">
					<a class="panelButton" href="${ctx}/fee/payable"><i class="ti-angle-left"></i> 返回</a>
				</h3>
			</div>
		</c:if>
	<!--判断发票子表的查看[如果触发的是发票子表的查看按钮，则不显示这些信息]-->
	<c:if test="${different ne 'invoicePage'}">
		<c:if test="${typeSign ne '1'}">
			<div class="panel-heading">
				<h3 class="panel-title">
					<a class="panelButton" href="${ctx}/fee/receivables"><i class="ti-angle-left"></i> 返回</a>
				</h3>
			</div>
			<br>
			<!-- 引入明细按钮 -->
			<c:if test="${(receivables.id ne null and receivables.status eq 0) or receivables.id eq null}">
				<button class="btn btn-primary btn-sm fl" onclick="model()">引入明细</button>
			</c:if>
		</c:if>
		<c:if test="${receivables.id ne null and receivables.status eq 0}">
			<a href="#" onclick="verify('${receivables.id}','form')"  class="btn btn-success btn-sm fl"><i class="fa fa-check"></i>确认</a>
		</c:if>
		<c:if test="${receivables.id ne null and (receivables.status eq 1 or receivables.status eq 2 or receivables.status eq 4)}">
			<!--判断发票子表的查看[如果触发的是发票子表的查看按钮，则不显示这些信息]-->
			<c:if test="${different ne 'invoicePage'}">
				<a href="#" onclick="bill('${receivables.id}')"  class="btn btn-success btn-sm margin-left fl"> 开票</a>
			</c:if>
		</c:if>

		<c:if test="${receivables.id ne null and receivables.status ne 0}">
			<%--纠错按钮[少收或者多收]--%>
			<a href="#" onclick="lessCorrect('${receivables.id}')"  class="btn btn-success btn-sm margin-left fl"> 少收补票</a>
			<a href="#" onclick="moreCorrect('${receivables.id}')"  class="btn btn-success btn-sm margin-left fl"> 多收冲账</a>
		</c:if>
		<%--关闭按钮--%>
		<c:if test="${receivables.id ne null and receivables.status ne 0}">
			<button class="btn btn-success btn-sm margin-left fl" data-toggle="modal" data-target="#myReason" id="reason">关闭结算单</button>
		</c:if>
		<c:if test="${receivables.id ne null}">
			<a href="#" onclick="refreshPage('${receivables.id}')"  class="btn btn-success btn-sm fl" style="margin-left:3px;"> 刷新</a>
		</c:if>
	</c:if>
		<div class="panel-body">
		<form:form id="inputForm" modelAttribute="receivables" action="${ctx}/fee/receivables/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
			<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
				<tbody>
				<tr>
					<c:if test="${receivables.clearingNo ne null}">
						<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>结算单号：</label></td>
						<td class="width-21">
							<form:input path="clearingNo" htmlEscape="false" class="form-control required"/>
						</td>
					</c:if>
					<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>结算日期：</label></td>
					<td class="width-21">
						<div class='input-group form_datetime' id='busyDate'>
							<input type='text' id="dd"  name="busyDate" class="form-control"  value="<fmt:formatDate value="${receivables.busyDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							<span class="input-group-addon">
			                        <span class="glyphicon glyphicon-calendar"></span>
			                    </span>
						</div>
					</td>
					<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>状态：</label></td>
					<td class="width-21">
						<form:select path="status" id="status" class="form-control required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('receivables_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
				</tr>
				<tr>
					<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>结算方：</label></td>
					<td class="width-21">
						<select name="payerName.id" id="consignorSelect" class="form-control required" value="${receivables.payerName.name}">
							<option value="">--请选择--</option>
							<c:forEach items="${consignors}" var="item">
								<option value="${item.id}" <c:if test="${item.name eq receivables.payerName.name}">selected</c:if>>${item.name}</option>
							</c:forEach>
						</select>
					</td>
						<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>结算金额：</label></td>
						<td class="width-21">
							<form:input path="payMoney" id="money" htmlEscape="false"    class="form-control required"/>
						</td>
					<td class="width-12 active"><label class="pull-right">开票金额：</label></td>
					<td class="width-21">
						<form:input path="invoiceMoney" id="invoiceMoney" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-12 active"><label class="pull-right">未开票金额：</label></td>
					<td class="width-21">
						<form:input path="noInvoiceMoney" htmlEscape="false"    class="form-control number"/>
					</td>
					<td class="width-12 active"><label class="pull-right">核销金额：</label></td>
					<td class="width-21">
						<form:input path="vcaMoney" htmlEscape="false"    class="form-control number"/>
					</td>
					<td class="width-12 active"><label class="pull-right">未核销金额：</label></td>
					<td class="width-21">
						<form:input path="noVcaMoney" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<c:if test="${receivables.id ne null and receivables.status eq 6}">
						<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>关闭原因：</label></td>
						<td class="width-21">
						<form:input path="closeReason" htmlEscape="false"    class="form-control "/>
						</td>
					</c:if>
					<c:if test="${payableId eq null and receId eq null}"><%--判断结算单id等于null时显示--%>
						<td class="width-12 active"><label class="pull-right">备注信息：</label></td>
						<td class="width-21">
							<form:input path="remarks" htmlEscape="false"    class="form-control "/>
						</td>
					</c:if>
					<c:if test="${payableId ne null or receId ne null}"><%--判断结算单id等于null时显示--%>
						<td class="width-12 active"><label class="pull-right"><font color="red">*&nbsp;</font>备注信息：</label></td>
						<td class="width-21">
							<%--<form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control required"/>--%>
							<form:input path="remarks" htmlEscape="false"    class="form-control required"/>
						</td>
					</c:if>
				</tr>
				</tbody>
			</table>
			<input type="hidden" id="ids" name="ids" value="${ids}"/>
			<%--点击应付结算单的多收冲账按钮时获取的结算单id[原结算单id]--%>
			<input type="hidden" id="payableId" name="payableId" value="${payableId}"/>
			<%--点击应收结算单的少收补票按钮时获取的结算单id[原结算单id]--%>
			<input type="hidden" id="receId" name="receId" value="${receId}"/>

			<div class="tabs-container tab-container">
				<ul class="nav nav-tabs nav-style">
					<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">费用明细</a>
					</li>
					<li class="tab_2"><a data-toggle="tab" href="#tab-2" aria-expanded="false">开票收款记录</a>
					</li>
				</ul>
				<div class="tab-content">
					<div id="tab-1" class="tab-pane active">
						<div  class="tableBox">
							<table id="contentTable"
								   class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
								<thead>
								<tr>
									<th><input type="checkbox" class="i-checks"></th>
									<th class="sort-column busyDate">业务日期</th>
									<th class="sort-column feeAgreeName.id">计费协议</th>
									<th class="sort-column feeType.id">费用类型</th>
									<th class="sort-column payMoney">计费金额</th>
									<th  class="sort-column clearingMoney">调整金额</th>
									<th>调整差额</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody id="detailTbody">
								<c:forEach items="${list}" var="feeReceivablesDetail" >
									<tr id="${feeReceivablesDetail.id}_name">
										<td><input type="checkbox" id="${feeReceivablesDetail.id}" class="i-checks"></td>
										<td>
											<c:if test="${flag eq 'feeDetail'}">
												<a href="#" onclick="jp.openDialogView('查看费用明细', '${ctx}/fee/detail/form?id=${feeReceivablesDetail.id}','800px', '500px')">
													<fmt:formatDate value="${feeReceivablesDetail.busyDate}" pattern="yyyy-MM-dd"/></a>
											</c:if>
											<c:if test="${flag eq 'receivables'}">
												<a href="#" onclick="jp.openDialogView('查看费用明细', '${ctx}/fee/detail/form?id=${feeReceivablesDetail.feeDetail.id}','800px', '500px')">
													<fmt:formatDate value="${feeReceivablesDetail.busyDate}" pattern="yyyy-MM-dd"/></a>
											</c:if>
										</td>
										<td>
												${feeReceivablesDetail.feeAgreeName.name}
										</td>
										<td>
												${feeReceivablesDetail.feeType.name}
										</td>
										<td class="coun" id="${feeReceivablesDetail.id}_payMoney" name="${feeReceivablesDetail.id}_payMoney">
											<fmt:formatNumber value="${feeReceivablesDetail.payMoney}" pattern="#.00"/>
										</td>
										<td>
											<fmt:formatNumber value="${feeReceivablesDetail.clearingMoney}" pattern="#.00"/>
										</td>
										<!--调整差额-->
										<td id="${feeReceivablesDetail.id}_adjustSpread">
											<!--根据调整金额判断[如果调整金额为null，调整差额则为null]-->
											<c:if test="${feeReceivablesDetail.clearingMoney ne null}">
												<fmt:formatNumber value="${(feeReceivablesDetail.payMoney - feeReceivablesDetail.clearingMoney)<0 ? -(feeReceivablesDetail.payMoney - feeReceivablesDetail.clearingMoney):(feeReceivablesDetail.payMoney - feeReceivablesDetail.clearingMoney)}" pattern="#.00"/>
											</c:if>
										</td>
										<td>
												<c:if test="${flag eq 'feeDetail'}">
													<a href="#"
													   onclick="jp.openDialogView('查看费用明细', '${ctx}/fee/detail/form?id=${feeReceivablesDetail.id}','800px', '500px')"
													   class="btn btn-info btn-xs"><i class="fa fa-search-plus"></i> 查看</a>
												</c:if>
												<c:if test="${flag eq 'receivables'}">
													<a href="#"
													   onclick="jp.openDialogView('查看费用明细', '${ctx}/fee/detail/form?id=${feeReceivablesDetail.feeDetail.id}','800px', '500px')"
													   class="btn btn-info btn-xs"><i class="fa fa-search-plus"></i> 查看</a>
												</c:if>
											<c:if test="${receivables.id eq null}">
												<input type="button" onclick="deleteInPage('${feeReceivablesDetail.id}')" value="删除"
													   class="btn btn-danger btn-xs"><!-- <i class="fa fa-trash"></i> -->
											</c:if>
											<c:if test="${receivables.id ne null and receivables.status eq 0}">
												<input type="button" onclick="deletes('${feeReceivablesDetail.id}')" value="删除"
													   class="btn btn-danger btn-xs"><!-- <i class="fa fa-trash"></i> -->
											</c:if>
										</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
					<div id="tab-2" class="tab-pane">
						<table class="detailedRecord">
							<c:forEach items="${iprList}" var="InvoicePayRecord" varStatus="num">
								<tr class="header">
									<td style="text-align:center;">
											${num.count}
									</td>
									<td  style="text-align:right;">
										发票号
									</td>
									<td>
											${InvoicePayRecord.invoiceNo}
									</td>
									<td style="text-align:right;">
										开票时间
									</td>
									<td>
										<fmt:formatDate value="${InvoicePayRecord.invoiceDate}" pattern="yyyy-MM-dd"/>
									</td>
									<td style="text-align:right;">
										开票金额
									</td>
									<td>
										￥<fmt:formatNumber value="${InvoicePayRecord.invMoney}" pattern="#.00"/>
									</td>
									<td style="text-align:right;">
										核销金额
									</td>
									<td>
										￥<fmt:formatNumber value="${InvoicePayRecord.theVcaMoney}" pattern="#.00"/>
									</td>
									<td style="text-align:right;">
										发票总金额
									</td>
									<td>
										￥<fmt:formatNumber value="${InvoicePayRecord.invoiceTotalMoney}" pattern="#.00"/>
									</td>
									<td style="text-align:right;">
										核销总金额
									</td>
									<td>
										￥<fmt:formatNumber value="${InvoicePayRecord.vcaTotalMoney == null ? 0 : InvoicePayRecord.vcaTotalMoney }" pattern="#.00"/>
									</td>
								</tr>
								<c:forEach items="${InvoicePayRecord.billDetails}" var="billDeatil">
									<tr class="detail">
										<td class="progressBar">
											<span></span>
										</td>
										<td style="text-align:right;">
											收款单号
										</td>
										<td style="">
												${billDeatil.feeBill.billNo}
										</td>
										<td style="text-align:right;">
											收款时间
										</td>
										<td>
											<fmt:formatDate value="${billDeatil.feeBill.billDate}" pattern="yyyy-MM-dd"/>
										</td>
										<td style="text-align:right;">
											收款金额
										</td>
										<td>
											￥<fmt:formatNumber value="${billDeatil.theVcaMoney}" pattern="#.00"/>
										</td>
									</tr>
								</c:forEach>
							</c:forEach>
						</table>
						<div class="total"><label class="first">合计：</label><p class="fr">开票：<label class="second">￥<fmt:formatNumber value="${totalInvoice}" pattern="#.00"/></label>核销：<label class="second">￥<fmt:formatNumber value="${totalVcamoney}" pattern="#.00"/></label></p></div>
					</div>
				</div>
			</div>
	<c:if test="${different ne 'invoicePage'}">
		<c:if test="${fns:hasPermission('fee:receivables:edit') || isAdd}">
				<div class="col-lg-3"></div>
		        <div class="col-lg-6">
		             <div class="form-group text-center">
		                 <div>
		                     <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
		                 </div>
		             </div>
		        </div>
		</c:if>
	</c:if>
		</form:form>
		</div>				
	</div>
	</div>
</div>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
	 aria-hidden="true">
	<div class="modal-dialog" style="width: 750px">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">计费费用列表</h4>
			</div>
			<div class="modal-body">
				<!-- 查询条件 -->
				<div class="row">
					<div class="col-sm-12">
						<form action="" method="post" class="form-inline" id="searchForm">
							<div class="form-group pull-left">
								<span>开始时间：</span>
								<input id="startDate" name="startDate" type="text" maxlength="20" class="laydate-icon form-control layer-date input-sm" style="width:137px;"
									   value="<fmt:formatDate value="${detail.startDate}" pattern="yyyy-MM-dd"/>"/>
							</div>
							<div class="form-group pull-left">
								<span>结束时间：</span>
								<input id="endDate" name="endDate" type="text" maxlength="20" class="laydate-icon form-control layer-date input-sm" style="width:137px;"
									   value="<fmt:formatDate value="${detail.endDate}" pattern="yyyy-MM-dd"/>"/>
							</div>

						</form>
						<div class="pull-right">
							<button  class="btn btn-primary btn-rounded btn-outline btn-sm " onclick="searchDetail()" ><i class="fa fa-search"></i> 查询</button>
							<button  class="btn btn-primary btn-rounded btn-outline btn-sm " onclick="reset()" ><i class="fa fa-refresh"></i> 重置</button>
						</div>
					</div>
				</div>
				<!-- 表格 -->
				<div class="table-box1">
					<table id="content"
						   class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable  tableAjax">
						<thead>
						<tr>
							<th><input type="checkbox" class="checkbox_css" id="allCheckBox" name="all"></th>
							<th class="sort-column status">状态</th>
							<th class="sort-column clearUnit.id">结算方</th>
							<th class="sort-column feeAgreement.id">计费协议</th>
							<th class="sort-column feeType.id">费用类型</th>
							<th class="sort-column busyDate">业务日期</th>
							<th class="sort-column">数据源</th>
							<th class="sort-column payMoney">计费金额</th>
							<th class="sort-column clearingMoney">调整金额</th>
							<th class="sort-column updateBy.id">调整人</th>
						</tr>
						</thead>
						<tbody id="detailLists">

						</tbody>
					</table>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-primary" onclick="detail()">确定</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
<%--关闭按钮的模态框--%>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myReason" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:500px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myCloseModalLabel">关闭原因</h4>
			</div>
			<div class="modal-body"  style="height:200px;">
				<input type="hidden" name="pId" value="${receivables.id}" id="pId" />
				<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
					<tbody>
					<tr>
						<td class="width-30 active"><label class="pull-right"><font color="red">*&nbsp;</font>关闭原因：</label></td>
						<td class="width-70">
							<input type="textarea" name="closeReason" value="" id="closeReason" placeholder="请输入关闭原因" class="form-control  number required"/>
						</td>
					</tr>
					</tbody>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-primary" id="confirmClose">确定</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
</body>
</html>